package p.ithorns.framework.core.model;

import lombok.Getter;
import lombok.Setter;

/**
 * PubPacket
 * <p>
 * 发布包
 * 包含消息类型(主题topic) 和 消息体
 *
 * @author liuhaitao
 * @version 1.0.0
 * @date 2022/4/21 14:26
 */
@Getter
@Setter
public class PubPacket<E> {

    /**
     * 消息类型
     */
    protected String type;

    /**
     * 消息数据
     */
    protected E body;


    protected PubPacket() {
    }

    protected PubPacket(String type, E body) {
        this.type = type;
        this.body = body;
    }

    public static <E> PubPacket<E> create(String type, E body) {
        return new PubPacket<>(type, body);
    }

}